package com.ysccc.shares;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import com.ysccc.shares.service.SharesService;
import com.ysccc.spring.boot.starter.sqldb.EnableJPAEnhance;
import com.ysccc.spring.boot.starter.web.commons.EnableSpringWebEnhance;
import com.ysccc.tools.Dates;

@SpringBootApplication
@ComponentScan(basePackages = { "com.ysccc" })
@EnableJPAEnhance
@EnableSpringWebEnhance
@EnableScheduling
public class Application implements ApplicationRunner {
	
	@Autowired
	private SharesService sharesService;

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
	
	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	@Override
	public void run(ApplicationArguments args) throws Exception {
		// 启动的时候统计一次数据
		sharesService.dailyReport(Dates.now());
		sharesService.alertSalsShares(Dates.now());
	}
}
